#ifndef __ADS1118_H_
#define __ADS1118_H_
// P4.4 -> OUT
// P4.5 -> CS
// P4.6 -> SCLK
// P4.7 -> IN
#include "io430.h"

#define PYDIR   P4DIR
#define PYOUT   P4OUT
#define PYIN    P4IN

#define ADS1118_CS_H     PYOUT |=BIT5
#define ADS1118_CS_L     PYOUT &=~BIT5
#define ADS1118_SCLK_H   PYOUT |=BIT6
#define ADS1118_SCLK_L   PYOUT &=~BIT6
#define ADS1118_DIN_H    PYOUT |=BIT7
#define ADS1118_DIN_L    PYOUT &=~BIT7

#define ADS1118_DOUT     PYIN&BIT4

#define Channel_0        0x40
#define Channel_1        0x50
#define Channel_2        0x60
#define Channel_3        0x70


void ADS1118_Init(void);
unsigned int Exchange_Data(unsigned int ADS_Data);
unsigned int Get_ADS1118(unsigned char Channel);

#endif

/* Bits[14:12]
 000 = AINP is AIN0 and AINN is AIN1 (default)
 001 = AINP is AIN0 and AINN is AIN3
 010 = AINP is AIN1 and AINN is AIN3
 011 = AINP is AIN2 and AINN is AIN3
 100 = AINP is AIN0 and AINN is GND
 101 = AINP is AIN1 and AINN is GND  
 110 = AINP is AIN2 and AINN is GND 
 111 = AINP is AIN3 and AINN is GND  */